$def with(form)
$:render.admin.header(css=['admin/css/ui.css','admin/css/popup.css','admin/css/media.css'],scripts=['scripts/libs/jquery.tools.min.js'])

$ isEditMode = form.submit.attrs['html'] != u'添加合作商家'

<style type="text/css">
    input[type="text"] {
        width: 200px !important;
    }
</style>
<script type="text/javascript">
    $$(function () {
        $$.tools.validator.fn('[name=name]', function (input, value) {
            value = $$.trim(value);
            if (value == '')
                return '请输入合作商家的名称。';
            return true;
        });
        $$.tools.validator.fn('[name=domain]', function (input, value) {
            value = $$.trim(value);
            if (value == '')
                return '请输入合作商家的域名。';
            return true;
        });
        $$.tools.validator.fn('[name=spread_url]', function (input, value) {
            value = $$.trim(value);
            if (value == '')
                return '请输入合作商家的推广连接模板。'
            return true;
        });
        $$('form').validator();
    });
</script>
$ tab_type_class = 'class="current"'
$if isEditMode:
    $ tab_type_class = ''
<div id="media-upload-header">
	<ul id="sidemenu">
		<li id="tab-type"><a href="$config.ADMIN_DIR/partner/add?mode=lite" $:tab_type_class>添加合作商家</a></li>
        $if isEditMode:
            <li id="tab-edit"><a href="javascript:;" class="current">$:form.submit.attrs['html']</a></li>
        <li id="tab-library"><a href="$config.ADMIN_DIR/partner?mode=lite">已有合作商家</a></li>
	</ul>
</div>

<form action="?mode=lite" method="post" class="media-upload-form">
    <h3>$:form.submit.attrs['html']</h3>
    <div id="media-items">
        <div class="media-item">
            <table class="slidetoggle describe">
                <tbody>
                    <tr class="post_title">
                        <th valign="top" scope="row" class="label"><label for="name"><span class="alignleft">名称</span><span class="alignright"><abbr title="required" class="required">*</abbr></span><br class="clear" /></label></th>
                        <td class="field">$:form.name.render()</td>
                    </tr>
                    <tr class="post_title">
                        <th valign="top" scope="row" class="label"><label for="domain"><span class="alignleft">域名</span><span class="alignright"><abbr title="required" class="required">*</abbr></span><br class="clear" /></label></th>
                        <td class="field">$:form.domain.render()<p>域名不要带http://</p></td>
                    </tr>
                    <tr class="post_title">
                        <th valign="top" scope="row" class="label"><label for="spread_url"><span class="alignleft">推广链接模板</span><span class="alignright"><abbr title="required" class="required">*</abbr></span><br class="clear" /></label></th>
                        <td class="field">$:form.spread_url.render()<p>使用%(url)s标识出需要替换每一条信息地址的位置。</p></td>
                    </tr>
                    <tr class="post_title">
                        <th valign="top" scope="row" class="label"><label for="sort"><span class="alignleft">排序值</span><span class="alignright"><abbr title="required" class="required">*</abbr></span><br class="clear" /></label></th>
                        <td
                            class="field">$:form.sort.render()<p>列表中，商家将按此字段值降序排列。</p></td>
                    </tr>
                    <tr class="submit">
                        <td></td>
                        <td class="savesend">$:form.submit.render()</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</form>

$:render.admin.footer()
